package com.haocang.szgm.ui.pipedata.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.data.BarEntry;
import com.haocang.commonlib.curve.BarChartManager;
import com.haocang.commonlib.network.interfaces.InitDataBeanBack;
import com.haocang.commonlib.network.interfaces.InitDataOneBeanBack;
import com.haocang.szgm.R;
import com.haocang.szgm.activity.comm.CommFinalActivity;
import com.haocang.szgm.requestcenter.DataModel;
import com.haocang.szgm.ui.analysis.activity.DataAnalysisActivity;
import com.haocang.szgm.ui.floodpoint.activity.ShotShareUtil;
import com.haocang.szgm.ui.pipedata.bean.BillStatisticsBean;
import com.haocang.szgm.ui.pipedata.bean.NetWorkInfoBean;
import com.haocang.szgm.utils.config.WebApi;
import com.haocang.szgm.utils.tools.MyTextUtils;

import net.tsz.afinal.annotation.view.ViewInject;

import java.util.ArrayList;
import java.util.List;

/**===============================================
 * 类 名 称：PipeDataActivity
 * 创建时间：2019/9/19 16:43
 * 编 写 人：ShenC
 * 类 说 明：管网数据展示 > 对应PC综合监管 管网
 *================================================
 * 修改内容：      修改时间：      修改人：
 *===============================================*/
public class PipeDataActivity extends CommFinalActivity {

    private Context context;

    @ViewInject(id = R.id.Bar_chat1)
    BarChart Bar_chat1;
    @ViewInject(id = R.id.sv_lin)
    ScrollView sv_lin;

    @ViewInject(id = R.id.pipe_user_01) TextView pipe_user_01;
    @ViewInject(id = R.id.pipe_user_02) TextView pipe_user_02;

    @ViewInject(id = R.id.pipe_alarm_01) TextView pipe_alarm_01;
    @ViewInject(id = R.id.pipe_alarm_02) TextView pipe_alarm_02;
    @ViewInject(id = R.id.pipe_alarm_03) TextView pipe_alarm_03;

    @ViewInject(id = R.id.pipe_assets_01) TextView pipe_assets_01;
    @ViewInject(id = R.id.pipe_assets_02) TextView pipe_assets_02;
    @ViewInject(id = R.id.pipe_assets_03) TextView pipe_assets_03;

    @ViewInject(id = R.id.pipe_yw_01) TextView pipe_yw_01;
    @ViewInject(id = R.id.pipe_yw_02) TextView pipe_yw_02;
    @ViewInject(id = R.id.pipe_yw_03) TextView pipe_yw_03;
    @ViewInject(id = R.id.pipe_yw_04) TextView pipe_yw_04;
    @ViewInject(id = R.id.pipe_yw_06) TextView pipe_yw_06;
    @ViewInject(id = R.id.pipe_yw_05) TextView pipe_yw_05;
    @ViewInject(id = R.id.pipe_yw_07) TextView pipe_yw_07;
    @ViewInject(id = R.id.pipe_yw_08) TextView pipe_yw_08;

    @ViewInject(id = R.id.pipe_yw_limte_01) TextView pipe_yw_limte_01;
    @ViewInject(id = R.id.pipe_yw_limte_02) TextView pipe_yw_limte_02;
    @ViewInject(id = R.id.pipe_yw_limte_03) TextView pipe_yw_limte_03;
    @ViewInject(id = R.id.pipe_yw_limte_04) TextView pipe_yw_limte_04;
    @ViewInject(id = R.id.pipe_yw_limte_05) TextView pipe_yw_limte_05;
    @ViewInject(id = R.id.pipe_yw_limte_06) TextView pipe_yw_limte_06;
    @ViewInject(id = R.id.pipe_yw_limte_07) TextView pipe_yw_limte_07;
    @ViewInject(id = R.id.pipe_yw_limte_08) TextView pipe_yw_limte_08;

    @ViewInject(id = R.id.lin_pipe_yw_01) LinearLayout lin_pipe_yw_01;
    @ViewInject(id = R.id.lin_pipe_yw_02) LinearLayout lin_pipe_yw_02;
    @ViewInject(id = R.id.lin_pipe_yw_03) LinearLayout lin_pipe_yw_03;
    @ViewInject(id = R.id.lin_pipe_yw_04) LinearLayout lin_pipe_yw_04;
    @ViewInject(id = R.id.lin_pipe_yw_05) LinearLayout lin_pipe_yw_05;
    @ViewInject(id = R.id.lin_pipe_yw_06) LinearLayout lin_pipe_yw_06;
    @ViewInject(id = R.id.lin_pipe_yw_07) LinearLayout lin_pipe_yw_07;
    @ViewInject(id = R.id.lin_pipe_yw_08) LinearLayout lin_pipe_yw_08;

    @ViewInject(id = R.id.pipe_yw_limte_arrow_01) ImageView arrow_01;
    @ViewInject(id = R.id.pipe_yw_limte_arrow_02) ImageView arrow_02;
    @ViewInject(id = R.id.pipe_yw_limte_arrow_03) ImageView arrow_03;
    @ViewInject(id = R.id.pipe_yw_limte_arrow_04) ImageView arrow_04;
//    @ViewInject(id = R.id.pipe_yw_limte_arrow_05) ImageView arrow_05;
//    @ViewInject(id = R.id.pipe_yw_limte_arrow_06) ImageView arrow_06;
    @ViewInject(id = R.id.pipe_yw_limte_arrow_07) ImageView arrow_07;
    @ViewInject(id = R.id.pipe_yw_limte_arrow_08) ImageView arrow_08;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        context = this;
        initView();

        initEvent();

        initData();

    }

    @Override
    protected int getLayoutResourceId() {
        return R.layout.activity_pipe_data;
    }

    @Override
    protected boolean showNavigation() {
        return true;
    }

    @Override
    protected int showMoreIcon() {
        return R.drawable.ic_share_black_24dp;
    }

    @Override
    protected String showTitleName() {
        return "管网";
    }


    private void initView() {
        //showBarChartAlong();
    }


    private void initEvent() {
        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
            }
        });
        iv_more.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ShotShareUtil.scrollViewScreenShot(PipeDataActivity.this, sv_lin, "pipe");
            }
        });


        lin_pipe_yw_01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(context, DataAnalysisActivity.class);
                it.putExtra("FromHome", false);
                it.putExtra("MPOINT", pipe_yw_01.getTag().toString());
                startActivity(it);
            }
        });

        lin_pipe_yw_02.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(context, DataAnalysisActivity.class);
                it.putExtra("FromHome", false);
                it.putExtra("MPOINT", pipe_yw_02.getTag().toString());
                startActivity(it);
            }
        });

        lin_pipe_yw_03.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(context, DataAnalysisActivity.class);
                it.putExtra("FromHome", false);
                it.putExtra("MPOINT", pipe_yw_03.getTag().toString());
                startActivity(it);
            }
        });


        lin_pipe_yw_04.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(context, DataAnalysisActivity.class);
                it.putExtra("FromHome", false);
                it.putExtra("MPOINT", pipe_yw_04.getTag().toString());
                startActivity(it);
            }
        });


        lin_pipe_yw_05.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(context, DataAnalysisActivity.class);
                it.putExtra("FromHome", false);
                it.putExtra("MPOINT", pipe_yw_05.getTag().toString());
                startActivity(it);
            }
        });


        lin_pipe_yw_06.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(context, DataAnalysisActivity.class);
                it.putExtra("FromHome", false);
                it.putExtra("MPOINT", pipe_yw_06.getTag().toString());
                startActivity(it);
            }
        });


        lin_pipe_yw_07.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(context, DataAnalysisActivity.class);
                it.putExtra("FromHome", false);
                it.putExtra("MPOINT", pipe_yw_07.getTag().toString());
                startActivity(it);
            }
        });

        lin_pipe_yw_08.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(context, DataAnalysisActivity.class);
                it.putExtra("FromHome", false);
                it.putExtra("MPOINT", pipe_yw_08.getTag().toString());
                startActivity(it);
            }
        });


    }



    private void initData(){

        DataModel.GetApiRequestMode("BillStatisticsBean", WebApi.Api_GetBillStatistics+"1", new InitDataBeanBack<BillStatisticsBean>() {
            @Override
            public void callbak(boolean b, List<BillStatisticsBean> list, String msg) {
                if(b){

                    if(list == null || list.size() == 0){
                        ToastShow("无工单数据");
                        return;
                    }

                    List<Float> xAxisValues = new ArrayList<>();
                    List<List<Float>> yAxisValues = new ArrayList<>();
                    List<String> labels = new ArrayList<>();
                    List<Float> x1 = new ArrayList<>();
                    List<Float> x2 = new ArrayList<>();
                    String[] xValues = new String[7];

                    float index = 1.0f;
                    for(int i= 0;i< list.size();i++){
                        BillStatisticsBean model = list.get(i);
                        xAxisValues.add(index);
                        x1.add(Float.parseFloat(model.getOverCheckCount()));
                        x2.add(Float.parseFloat(model.getInCheckCount()));
                        xValues[i] = model.getTitle();
                        index += 1.0f;
                    }

                    yAxisValues.add(x1);
                    yAxisValues.add(x2);
                    labels.add("");
                    labels.add("");
                    showBarChartMore(xAxisValues,yAxisValues,labels,xValues);
                }else{
                    ToastShow(msg);
                }

            }
        });


        DataModel.GetApiRequestOneMode("NetWorkInfoBean", WebApi.Api_GetNetWorkInfo, new InitDataOneBeanBack<NetWorkInfoBean>() {
            @Override
            public void callbak(boolean b, NetWorkInfoBean data, String msg) {
                if(b){

                    if(data != null) {

                        if(data.getUserStatistics() != null) {
                          pipe_user_01.setText(data.getUserStatistics().getOnLineCount());
                          pipe_user_02.setText(data.getUserStatistics().getAllUserCount());
                        }

                        if(data.getNetworkAlarm() != null) {
                            pipe_alarm_01.setText(data.getNetworkAlarm().getQualityCount());
                            pipe_alarm_02.setText(data.getNetworkAlarm().getWaterAmountCount());
                            pipe_alarm_03.setText(data.getNetworkAlarm().getEquipment());
                        }

                        if(data.getAssets() != null) {
                            pipe_assets_01.setText(data.getAssets().getWaterNewworkCount().equals("0")?"-":data.getAssets().getWaterNewworkCount());
                            pipe_assets_02.setText(data.getAssets().getSewageNewworkCount().equals("0")?"-":data.getAssets().getSewageNewworkCount());
                            pipe_assets_03.setText(data.getAssets().getCarCount());
                        }

                        if(data.getRealTimeBoxCulvert().size() >=6) {

                            List<NetWorkInfoBean.RealTimeBean> realtime_list = data.getRealTimeBoxCulvert();

                            String str_value1 = realtime_list.get(0).getValue() + "m";
                            String str_value2 = realtime_list.get(1).getValue() + "m";
//                            String str_value3 = realtime_list.get(2).getValue() + "m";
                            String str_value4 = realtime_list.get(3).getValue() + "m";
                            String str_value5 = realtime_list.get(4).getValue() + "m";
//                            String str_value6 = realtime_list.get(5).getValue() + "m";
//                            String str_value7 = realtime_list.get(6).getValue() + "m";
//                            String str_value8 = realtime_list.get(7).getValue() + "m";
                            String str_value7 = realtime_list.get(5).getValue() + "m";
                            String str_value8 = realtime_list.get(6).getValue() + "m";
                            pipe_yw_01.setText(str_value1);
                            pipe_yw_02.setText(str_value2);
//                            pipe_yw_06.setText(str_value3);
                            pipe_yw_03.setText(str_value4);
                            pipe_yw_04.setText(str_value5);
//                            pipe_yw_05.setText(str_value6);
                            pipe_yw_07.setText(str_value7);
                            pipe_yw_08.setText(str_value8);


                            if(!MyTextUtils.IsNullByString(realtime_list.get(0).getAlarmValue())){
                                pipe_yw_limte_01.setText("(限值:"+realtime_list.get(0).getAlarmValue()+"m)");
                            }else{
                                pipe_yw_limte_01.setText("");
                            }

                            if(!MyTextUtils.IsNullByString(realtime_list.get(0).getTypeName())){
                                if (realtime_list.get(0).getTypeName().indexOf("")!=-1){
                                    if (realtime_list.get(0).getTypeName().contains("上")){
                                        arrow_01.setImageResource(R.mipmap.up_arrow);
                                    }else {
                                        arrow_01.setImageResource(R.mipmap.down_arrow);
                                    }
                                }
                            }

                            if(!MyTextUtils.IsNullByString(realtime_list.get(1).getAlarmValue())){
                                pipe_yw_limte_02.setText("(限值:"+realtime_list.get(1).getAlarmValue()+"m)");
                            }else{
                                pipe_yw_limte_02.setText("");
                            }

                            if(!MyTextUtils.IsNullByString(realtime_list.get(1).getTypeName())){
                                if (realtime_list.get(1).getTypeName().indexOf("")!=-1){
                                    if (realtime_list.get(1).getTypeName().contains("上")){
                                        arrow_02.setImageResource(R.mipmap.up_arrow);
                                    }else {
                                        arrow_02.setImageResource(R.mipmap.down_arrow);
                                    }
                                }
                            }

                            if(!MyTextUtils.IsNullByString(realtime_list.get(3).getAlarmValue())){
                                pipe_yw_limte_03.setText("(限值:"+realtime_list.get(3).getAlarmValue()+"m)");
                            }else{
                                pipe_yw_limte_03.setText("");
                            }

                            if(!MyTextUtils.IsNullByString(realtime_list.get(3).getTypeName())){
                                if (realtime_list.get(3).getTypeName().indexOf("")!=-1){
                                    if (realtime_list.get(3).getTypeName().contains("上")){
                                        arrow_03.setImageResource(R.mipmap.up_arrow);
                                    }else {
                                        arrow_03.setImageResource(R.mipmap.down_arrow);
                                    }
                                }
                            }


                            if(!MyTextUtils.IsNullByString(realtime_list.get(4).getAlarmValue())){
                                pipe_yw_limte_04.setText("(限值:"+realtime_list.get(4).getAlarmValue()+"m)");
                            }else{
                                pipe_yw_limte_04.setText("");
                            }
                            if(!MyTextUtils.IsNullByString(realtime_list.get(4).getTypeName())){
                                if (realtime_list.get(4).getTypeName().indexOf("")!=-1){
                                    if (realtime_list.get(4).getTypeName().contains("上")){
                                        arrow_04.setImageResource(R.mipmap.up_arrow);
                                    }else {
                                        arrow_04.setImageResource(R.mipmap.down_arrow);
                                    }
                                }
                            }


//                            if(!MyTextUtils.IsNullByString(realtime_list.get(5).getAlarmValue())){
//                                pipe_yw_limte_05.setText("(限值:"+realtime_list.get(5).getAlarmValue()+"m)");
//                            }else{
//                                pipe_yw_limte_05.setText("");
//                            }
//                            if(!MyTextUtils.IsNullByString(realtime_list.get(2).getAlarmValue())){
//                                pipe_yw_limte_06.setText("(限值:"+realtime_list.get(2).getAlarmValue()+"m)");
//                            }else{
//                                pipe_yw_limte_06.setText("");
//                            }

//                            if(!MyTextUtils.IsNullByString(realtime_list.get(6).getAlarmValue())){
//                                pipe_yw_limte_07.setText("(限值:"+realtime_list.get(6).getAlarmValue()+"m)");
//                            }else{
//                                pipe_yw_limte_07.setText("");
//                            }
//
//                            if(!MyTextUtils.IsNullByString(realtime_list.get(7).getAlarmValue())){
//                                pipe_yw_limte_08.setText("(限值:"+realtime_list.get(7).getAlarmValue()+"m)");
//                            }else{
//                                pipe_yw_limte_08.setText("");
//                            }


                            if(!MyTextUtils.IsNullByString(realtime_list.get(5).getAlarmValue())){
                                pipe_yw_limte_07.setText("(限值:"+realtime_list.get(5).getAlarmValue()+"m)");
                            }else{
                                pipe_yw_limte_07.setText("");
                            }

                            if(!MyTextUtils.IsNullByString(realtime_list.get(5).getTypeName())){
                                if (realtime_list.get(5).getTypeName().indexOf("")!=-1){
                                    if (realtime_list.get(5).getTypeName().contains("上")){
                                        arrow_07.setImageResource(R.mipmap.up_arrow);
                                    }else {
                                        arrow_07.setImageResource(R.mipmap.down_arrow);
                                    }
                                }
                            }


                            if(!MyTextUtils.IsNullByString(realtime_list.get(6).getAlarmValue())){
                                pipe_yw_limte_08.setText("(限值:"+realtime_list.get(6).getAlarmValue()+"m)");
                            }else{
                                pipe_yw_limte_08.setText("");
                            }

                            if(!MyTextUtils.IsNullByString(realtime_list.get(6).getTypeName())){
                                if (realtime_list.get(6).getTypeName().indexOf("")!=-1){
                                    if (realtime_list.get(6).getTypeName().contains("上")){
                                        arrow_08.setImageResource(R.mipmap.up_arrow);
                                    }else {
                                        arrow_08.setImageResource(R.mipmap.down_arrow);
                                    }
                                }
                            }



//                            offline
                            if(MyTextUtils.IsNullByString(realtime_list.get(0).getPriority())){
                                lin_pipe_yw_01.setBackgroundResource(R.drawable.bt_green_02);
                            }else if(realtime_list.get(0).getPriority().equals("gray")){//危险
                                lin_pipe_yw_01.setBackgroundResource(R.drawable.bt_red_02);
                            }else if(realtime_list.get(0).getPriority().equals("offline")){//变成灰色
                                lin_pipe_yw_01.setBackgroundResource(R.drawable.bt_gray_02);
                            }else{//警戒
                                lin_pipe_yw_01.setBackgroundResource(R.drawable.bt_orange_01);
                            }

                            if(MyTextUtils.IsNullByString(realtime_list.get(1).getPriority())){
                                lin_pipe_yw_02.setBackgroundResource(R.drawable.bt_green_02);
                            }else if(realtime_list.get(1).getPriority().equals("gray")){//危险
                                lin_pipe_yw_02.setBackgroundResource(R.drawable.bt_red_02);
                            }else if(realtime_list.get(1).getPriority().equals("offline")){//变成灰色
                                lin_pipe_yw_02.setBackgroundResource(R.drawable.bt_gray_02);
                            }else{//警戒
                                lin_pipe_yw_02.setBackgroundResource(R.drawable.bt_orange_01);
                            }


//                            if(MyTextUtils.IsNullByString(realtime_list.get(2).getPriority())){
//                                lin_pipe_yw_06.setBackgroundResource(R.drawable.bt_green_02);
//                            }else if(realtime_list.get(2).getPriority().equals("gray")){//危险
//                                lin_pipe_yw_06.setBackgroundResource(R.drawable.bt_red_02);
//                            }else if(realtime_list.get(2).getPriority().equals("offline")){//变成灰色
//                                lin_pipe_yw_06.setBackgroundResource(R.drawable.bt_gray_02);
//                            }else{//警戒
//                                lin_pipe_yw_06.setBackgroundResource(R.drawable.bt_orange_01);
//                            }

                            if(MyTextUtils.IsNullByString(realtime_list.get(3).getPriority())){
                                lin_pipe_yw_03.setBackgroundResource(R.drawable.bt_green_02);
                            }else if(realtime_list.get(3).getPriority().equals("gray")){//危险
                                lin_pipe_yw_03.setBackgroundResource(R.drawable.bt_red_02);
                            }else if(realtime_list.get(3).getPriority().equals("offline")){//变成灰色
                                lin_pipe_yw_03.setBackgroundResource(R.drawable.bt_gray_02);
                            }else{//警戒
                                lin_pipe_yw_03.setBackgroundResource(R.drawable.bt_orange_01);
                            }

                            if(MyTextUtils.IsNullByString(realtime_list.get(4).getPriority())){
                                lin_pipe_yw_04.setBackgroundResource(R.drawable.bt_green_02);
                            }else if(realtime_list.get(4).getPriority().equals("gray")){//危险
                                lin_pipe_yw_04.setBackgroundResource(R.drawable.bt_red_02);
                            }else if(realtime_list.get(4).getPriority().equals("offline")){//变成灰色
                                lin_pipe_yw_04.setBackgroundResource(R.drawable.bt_gray_02);
                            }else{//警戒
                                lin_pipe_yw_04.setBackgroundResource(R.drawable.bt_orange_01);
                            }

//                            if(MyTextUtils.IsNullByString(realtime_list.get(5).getPriority())){
//                                lin_pipe_yw_05.setBackgroundResource(R.drawable.bt_green_02);
//                            }else if(realtime_list.get(5).getPriority().equals("gray")){//危险
//                                lin_pipe_yw_05.setBackgroundResource(R.drawable.bt_red_02);
//                            }else if(realtime_list.get(5).getPriority().equals("offline")){//变成灰色
//                                lin_pipe_yw_05.setBackgroundResource(R.drawable.bt_gray_02);
//                            }else{//警戒
//                                lin_pipe_yw_05.setBackgroundResource(R.drawable.bt_orange_01);
//                            }
//
//                            if(MyTextUtils.IsNullByString(realtime_list.get(6).getPriority())){
//                                lin_pipe_yw_07.setBackgroundResource(R.drawable.bt_green_02);
//                            }else if(realtime_list.get(6).getPriority().equals("gray")){//危险
//                                lin_pipe_yw_07.setBackgroundResource(R.drawable.bt_red_02);
//                            }else if(realtime_list.get(6).getPriority().equals("offline")){//变成灰色
//                                lin_pipe_yw_07.setBackgroundResource(R.drawable.bt_gray_02);
//                            }else{//警戒
//                                lin_pipe_yw_07.setBackgroundResource(R.drawable.bt_orange_01);
//                            }
//
//                            if(MyTextUtils.IsNullByString(realtime_list.get(7).getPriority())){
//                                lin_pipe_yw_08.setBackgroundResource(R.drawable.bt_green_02);
//                            }else if(realtime_list.get(7).getPriority().equals("gray")){//危险
//                                lin_pipe_yw_08.setBackgroundResource(R.drawable.bt_red_02);
//                            }else if(realtime_list.get(7).getPriority().equals("offline")){//变成灰色
//                                lin_pipe_yw_08.setBackgroundResource(R.drawable.bt_gray_02);
//                            }else{//警戒
//                                lin_pipe_yw_08.setBackgroundResource(R.drawable.bt_orange_01);
//                            }


                            if(MyTextUtils.IsNullByString(realtime_list.get(5).getPriority())){
                                lin_pipe_yw_07.setBackgroundResource(R.drawable.bt_green_02);
                            }else if(realtime_list.get(5).getPriority().equals("gray")){//危险
                                lin_pipe_yw_07.setBackgroundResource(R.drawable.bt_red_02);
                            }else if(realtime_list.get(5).getPriority().equals("offline")){//变成灰色
                                lin_pipe_yw_07.setBackgroundResource(R.drawable.bt_gray_02);
                            }else{//警戒
                                lin_pipe_yw_07.setBackgroundResource(R.drawable.bt_orange_01);
                            }

                            if(MyTextUtils.IsNullByString(realtime_list.get(6).getPriority())){
                                lin_pipe_yw_08.setBackgroundResource(R.drawable.bt_green_02);
                            }else if(realtime_list.get(6).getPriority().equals("gray")){//危险
                                lin_pipe_yw_08.setBackgroundResource(R.drawable.bt_red_02);
                            }else if(realtime_list.get(6).getPriority().equals("offline")){//变成灰色
                                lin_pipe_yw_08.setBackgroundResource(R.drawable.bt_gray_02);
                            }else{//警戒
                                lin_pipe_yw_08.setBackgroundResource(R.drawable.bt_orange_01);
                            }


                            pipe_yw_01.setTag(realtime_list.get(0).getMpointID() );
                            pipe_yw_02.setTag(realtime_list.get(1).getMpointID() );
//                            pipe_yw_06.setTag(realtime_list.get(3).getMpointID() );
                            pipe_yw_03.setTag(realtime_list.get(3).getMpointID() );
                            pipe_yw_04.setTag(realtime_list.get(4).getMpointID() );
//                            pipe_yw_05.setTag(realtime_list.get(4).getMpointID() );
                            pipe_yw_07.setTag(realtime_list.get(5).getMpointID() );
                            pipe_yw_08.setTag(realtime_list.get(6).getMpointID() );

                        }

                    }

                }else{
                    ToastShow(msg);
                }


            }
        });


    }


    //显示2条柱状图
    private void showBarChartMore(List<Float> xAxisValues, List<List<Float>> yAxisValues,List<String> labels,String[] xValues ) {
        BarChartManager barChartManager = new BarChartManager(Bar_chat1);
        List<Integer> colours = new ArrayList<>();
        colours.add(Color.parseColor("#00c2ae"));
        colours.add(Color.parseColor("#00a2ee"));
        barChartManager.showMoreBarChart(xAxisValues, yAxisValues, labels, colours,xValues);
        barChartManager.setXAxis(7, 0, 10);
    }

    /**
     * 显示单条柱状图
     */
    private void showBarChartAlong() {
        BarChartManager barChartManager = new BarChartManager(Bar_chat1);

        List<BarEntry> yVals = new ArrayList<>();
        yVals.add(new BarEntry(1f, 80f));
        yVals.add(new BarEntry(2f, 50f));
        yVals.add(new BarEntry(3f, 60f));
        yVals.add(new BarEntry(4f, 60f));
        yVals.add(new BarEntry(5f, 70f));
        yVals.add(new BarEntry(6f, 80f));
        String label = "xxxxx";

        barChartManager.showBarChart(yVals, label, Color.parseColor("#233454"));

    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            finish();
            overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
            return super.onKeyDown(keyCode, event);
        } else {
            return false;
        }
    }
}
